#include <vector>
#include <algorithm>
using namespace std;
/*
 * @lc app=leetcode.cn id=66 lang=cpp
 *
 * [66] 加一
 */

// @lc code=start
class Solution {
public:
    vector<int> plusOne(vector<int>& digits) {
        int count = 1; vector<int> res; int i = digits.size() - 1;
        while (count != 0 || i >= 0) {
            int num = 0;
            if (i >= 0) num += digits[i];
            num += count;
            count = num / 10;
            res.push_back(num % 10);
            i--;
        }
        reverse(res.begin(), res.end());
        return res;
    }
};
// @lc code=end

